#include "find_min_dist.h"

int main(int argc, char *argv[])
{
    int m, n, i;
    int mindist;
    int threads = 0, metodo = 0;
    T_ADJ ruas;

    if (argc > 1)
        metodo = atoi(argv[1]);
    if (argc > 2)
        threads = atoi(argv[2]);

    // Read input (junctions and streets)
    scanf("%d %d", &n, &m);

    // Create matrix
    ruas.resize( n );

    // Create distance graph
    for (i = 0; i < m; ++i)
    {
        int x, y, c;
        scanf("%d %d %d", &x, &y, &c);

        ruas[x-1].push_back(Line(y-1,c));
        ruas[y-1].push_back(Line(x-1,c));
    }

    mindist = findBestPlace(metodo, ruas, threads);

    printf("%d\n", mindist);

    return 0;
}
